home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group99a.txt / 000069_icon-group-sender _Tue Mar 30 15:32:46 1999.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id PAA14056
  4.     for icon-group-addresses; Tue, 30 Mar 1999 15:32:39 -0700 (MST)
  5. Message-Id: <199903302232.PAA14056@baskerville.CS.Arizona.EDU>
  6. Date: Tue, 30 Mar 1999 16:04:23 -0600
  7. From: Steve Graham <graham@cowboy.biomed.com>
  8. X-Accept-Language: en
  9. To: Icon Mailing List <icon-group@optima.CS.Arizona.EDU>
  10. Subject: [Fwd: Problem reading binary file]
  11. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  12. Status: RO
  13.  
  14. Hello again.
  15.  
  16. Turns out that the problem with this was that the 7th character was an
  17. ASCII 26 (^Z) and Icon would not read any further than that.  I created
  18. a 2nd file with a ^Z in a different position and got a similar result. 
  19. This is despite the fact that there were over 25,000 characters
  20. following the Control Z.
  21.  
  22. So, my question is:  Why does Icon stop reading when it hits a ^Z?  I
  23. can kind of understand this if I were reading a text file; but I was
  24. specifically using reads() because this is a binary file?  Should not
  25. reads() support all 256 ASCII codes and only stop reading when there are
  26. REALLY no more characters to read?  I ended up using another language,
  27. which was significantly harder for me, to read the binary characters.
  28.  
  29. In Icon's defense, I notice that when I TYPE the above-mentioned 2nd
  30. file, I only see the characters occurring prior to the ^Z.  And I do not
  31. want it to appear that I am questioning Icon's usefulness.  It is
  32. normally one of the 1st languages I choose for utilities of this type.
  33.  
  34. Comments?
  35.  
  36.  
  37. Steve Graham
  38.  
  39. ===
  40.  
  41. Steve Graham wrote:
  42. > Hello.
  43. > I am using MS-DOS Icon 9.1 to read a binary file.  After reading 6
  44. > characters, the program apparently quits reading.  I have attached the
  45. > relevant portion of the code:
  46. > -------------------------- Code ------------------------------
  47. > procedure main(args)
  48. > #
  49. >   cnt := 0
  50. >   in  := open(args[1],"r") | stop("Unable to open ",args[1])
  51. >   out := open(args[2],"w") | stop("Unable to open ",args[2])
  52. >   while character := reads(in,1) do {
  53. >      write(character," -->", ord(character))
  54. >      cnt := cnt+1
  55. >     }
  56. >   close(in,out)
  57. >   write(cnt," characters transferred")
  58. > end
  59. > -----------------------End of Code-------------------------
  60. > I invoke the program with:
  61. > word r99-0059.doc r99-0059.txt
  62. > I get output of (some unprintable characters are represent by _):
  63. > - -->208
  64. > - -->207
  65. >  -->17
  66. > _ -->224
  67. > ∩┐╜ -->161
  68. > _ -->177
  69. > 6 characters transferred
  70. > Any ideas?
  71. > Thanks in advance.
  72. > -- Steve
  73. > ______________________________________________________
  74. > Steve Graham
  75. > Laboratory Corporation of America (LabCorp)
  76. > 12160 Abrams Road, Suite 601
  77. > Dallas, Texas 75243
  78. > E-mail: graham@cowboy.biomed.com
  79. > Phone:  972.643.6124  (direct to desk)
  80. >         972.437.5255 ext 5224
  81. > FAX:    972.454.1040
  82. > _______________________________________________________
  83.